/*
 * Screen class takes care of everything 
 * related to screen size and mode
 */

var Screen = Class.create({
    initialize: function() {
        this.MINI_VIEW_THRESHOLD = 150; // Sets the screen height threshold value for miniview
        this.container = $("container");
    },

	// Returns screen size in pixels
    getSize: function() {
        return {
            width: window.innerWidth,
            height: window.innerHeight
        };
    },

	// Recognizes the landscape mode
    isLandscape: function() {
        var size = this.getSize();
        return ( size.width > size.height );
    },

    // This is not needed in Qype S60 WRT widget,
	// but is so common that we left it as an example of 
	// how to extend the functionality
    isMiniViewMode: function() {
        return ((this.getSize()).height < this.MINI_VIEW_THRESHOLD);
    },

	/*
	 * Resize function simply adds the screen mode class
	 * into DOM tree: thus you can create landscape and
	 * portrait speficic CSS formatting without any
	 * code involved 
	 * (As an example, take a look on image used in PlaceView.js)
	 * 
	 * In case you are willing to have more complex 
	 * landscape/portrait adaptation, this is the place
	 * to add them
	 */
    resize: function() {
        util.log("{Screen.prototype.resize} start");
        if(this.isLandscape()) {
            this.container.addClassName("landscape");
            this.container.removeClassName("portrait");
        }
        else {
            this.container.removeClassName("landscape");
            this.container.addClassName("portrait");
        }
    }
});
